﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Things.Common;
using LTP.Accounts.Bus;
namespace Things.Web.GoodsPrice
{
    public partial class Add : Page
    {
        public Guid GoodsID
        {
            get
            {
                Guid goodsID = Guid.Empty;

                if (Request.Params["ID"] != null && Request.Params["ID"].Trim() != "")
                {
                    Guid.TryParse(Request.Params["ID"], out goodsID);
                }

                return goodsID;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtGoodsPriceType.Text.Trim().Length == 0)
            {
                strErr += "商品销售方式不能为空！\\n";
            }
            if (!PageValidate.IsDecimal(txtGoodsCurrentPrice.Text))
            {
                strErr += "当前价格格式错误！\\n";
            }
            if (!PageValidate.IsDecimal(txtGoodsStandPrice.Text))
            {
                strErr += "市场价格格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string GoodsPriceType = this.txtGoodsPriceType.Text;
            decimal GoodsCurrentPrice = decimal.Parse(this.txtGoodsCurrentPrice.Text);
            decimal GoodsStandPrice = decimal.Parse(this.txtGoodsStandPrice.Text);

            Things.Model.GoodsPrice model = new Things.Model.GoodsPrice();
            model.GoodsID = GoodsID;
            model.GoodsPriceType = GoodsPriceType;
            model.GoodsCurrentPrice = GoodsCurrentPrice;
            model.GoodsStandPrice = GoodsStandPrice;

            Things.BLL.GoodsPrice bll = new Things.BLL.GoodsPrice();
            bll.Add(model);
            Things.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "list.aspx?ID="+GoodsID.ToString());

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx?ID=" + GoodsID.ToString());
        }
    }
}
